{include file="public/head"}
<style>
	.yzl{
		float:right;height: 3rem;line-height:3rem;display: inline;padding-top:10%
	}
	.yzl li{
		float: left;color: #00cc7d;font-size: .5rem; width: .8rem;height: .8rem;text-align: center;line-height: .8rem;
	}
	.yzl li img{
		width: 100%;
	}
</style>
<!--loading页开始-->
<div class="loading">
	<div class="loader">
        <div class="loader-inner pacman">
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
        </div>
	</div>
</div>
<!--loading页结束-->
	<body>
		<!--header star-->
		<header class="mui-bar mui-bar-nav" id="header">
			<a class="btn" href="javascript:history.go(-1)">
	            <i class="iconfont icon-fanhui"></i>
	        </a>
	        <div class="top-sch-box top-sch-boxtwo flex-col">
	                     {$shopinfo.shop_name}
	        </div>
	        <a class="btn" href="#">
	           
	        </a>
	    </header>
	    <!--header end-->
	
	    <div class="warp warptwo clearfloat">
	    	<div class="shopcar clearfloat">
	    		{volist name="data" id="vol"}
	    		<div class="list clearfloat fl">
	    			
	    			<a href="{:url('goodinfo')}?goods_id={$vol.goods_id}">
		    			<div class="tu clearfloat fl">
		    				<span></span>
		    				<img src="/shop/upload/{$vol.picture}" style="height:100%;width:100%"/>
		    			</div>
		    			<div class="right clearfloat fl" style="width:42%">
		    				<p class="tit over">{$vol.goods_name}</p>
		    				{if $vol.promotion_type=="1"}
		    				<p class="jifen over"><span style="color:#000;font-size:0.4rem">原&nbsp;&nbsp;&nbsp;价：</span><s style="color:red">￥{$vol.price}</s></p>
		    				{/if}
		    				{if $vol.promotion_type=="0"}
		    				<p class="jifen over"></p>
		    				{/if}
		    				<p class="jifen over" style="color:red">{if $vol.promotion_type=="1"}<span style="color:#000;font-size:0.4rem">促销价：</span>{/if}￥{$vol.salesprice}</p>
		    				
		    			</div>
		    		</a>
    					<div class="zuo clearfloat fl yzl" >
    						<ul style="display: block">
    							<li><img src="static/shop/img/jian.png" onclick="desc('{$vol.goods_id}')" /></li>
    							<li><input type="text"  value="{$shopcart[$vol.goods_id]? $shopcart[$vol.goods_id] : 0}" style="width:100%;height:auto;padding:0px 0px;border:0px solid white;text-align:center" readonly id="goodnum{$vol.goods_id}"  name="goods_id[{$vol.goods_id}]" /></li>
    							<li><img src="static/shop/img/jia.png" onclick="add('{$vol.goods_id}')"/></li>
    						</ul>
    					</div>			
	    			
	    		</div>
	    		{/volist}	
	    		<input type="hidden" name="shop_id" value="{$shopinfo.shop_id}"/>
	    		<input type="hidden" name="shop_name" value="{$shopinfo.shop_name}"/>
	    	</div>
	    </div>
	    
	    <!--settlement star-->
	    <div class="settlement clearfloat">
	    	<div class="zuo clearfloat fl box-s" style="width:35%;text-align:right;padding-right:0px">
	    		合计：<span>￥</span>
	    	</div>
	    	<div class="" style="width:25%;float:left;text-align: left;padding-right:0px">
	    		<input type="text" readonly value="{$ordermoney}" style="border:0px solid red;padding-left:0px;color:red" id="ordermoney" name="ordermoney"/>
	    	</div>
	    	<a href="#" class="fl db" onclick="submit_form()">
	    		立即结算
	    	</a>
	    </div>
	    <br/><br/><br/>
	
	    <!--settlement end-->
	    
		<!--footer star-->
	    {include file="public/bottom"}
		<!--footer end-->
	</body>
	
</html>
<script type="text/javascript">
	function add(t){
		
		var num=document.getElementById('goodnum'+t).value;
		var num=parseInt(num)+1;
		$.post("{:url('cartAdd')}",{goods_id:t},function(res){
			if(res){
				
				document.getElementById('goodnum'+t).value=num;
				jisuan();
			}
		},'html');
		
		
	}
	function desc(t){
		var num1=document.getElementById('goodnum'+t).value;
		var num=parseInt(num1)-1;
		if(num1!='0'){
			$.post("{:url('cartDec')}",{goods_id:t},function(res){
				if(res){
					

					document.getElementById('goodnum'+t).value=num;
					jisuan();
				}
			},'html');
			
		}
		
	}
	
	function jisuan(){
		var shop_id={$shopinfo.shop_id};
		$.post("{:url('cartMoney')}",{shop_id:shop_id},function(res){
			document.getElementById('ordermoney').value=res;
		},'html');
	}
	jisuan();
	function submit_form(){
		var num={$num};
		if(num=="0"){
			alert('请先添加收货地址');
			window.location.href="{:url('user/addAddress')}";
			return false;
		}
		var ordermoney=$('#ordermoney').val();
		console.log(ordermoney);
		if(ordermoney>0){
			window.location.href="{:url('shopcart')}?shop_id={$shopinfo.shop_id}";
		}else{
			alert('请选择要购买的商品');
		}
	}
	
	

	
</script>